import { createRouter, createWebHashHistory } from 'vue-router'
import { createRouterGuards } from './routerGuards'

const router = createRouter({
  history: createWebHashHistory(),
  strict: true,
  routes: [
    {
      path: '/',
      name: 'index',
      redirect: '/login',
      component: () => import('@/views/pages/login.vue'),
      meta: {
        title: '首页',
      },
      children: [
        {
          path: '/login',
          name: 'login',
          component: () => import('@/views/pages/login.vue'),
          meta: {
            title: '登录',
          },
        }
      ],
    },
  ],
})

export function setupRouter (app) {
  app.use(router)
  // 创建路由守卫
  createRouterGuards(router)
}

export default router
